from django.db import models

# Create your models here.
class User(models.Model):
    username=models.CharField(max_length=20)
    password=models.CharField(max_length=20)

class Category(models.Model):
    name=models.CharField(max_length=50)
    parent = models.ForeignKey('self', null=True, on_delete=models.SET_NULL, related_name='children')

class Book(models.Model):
    name = models.CharField(max_length=50)
    category=models.ForeignKey(Category,on_delete=models.CASCADE,related_name='children1')
    status=models.BooleanField(default=False)
    description=models.TextField(null=True)
    created_at=models.DateTimeField(auto_now_add=True,null=True)
    price=models.DecimalField(max_digits=10, decimal_places=2)
    grade=models.IntegerField(choices=[(1,'小学'),(2,'初中'),(3,'高中')])
